home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXT Education Software Sampler 1992 Fall
/
NeXT Education Software Sampler 1992 Fall.iso
/
SoundAndMusic
/
cmix
/
filters
/
ellipse.mac.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-12-09
|
1KB
|
64 lines
#include "../H/ugens.h"
#include "ellipse.h"
ell(p,n_args)
float *p;
int n_args;
{
float ps[10][4],c[10][4],xnorm;
long i,nsamps,nchin,nchout;
float ellipse(),x[4],y[4];
int nsects;
nsamps=setnote(p[0],p[1],1);
setnote(p[2],p[1],0);
nchin = p[3];
nchout = p[4];
ellpset(&p[5],ps,c,&xnorm,&nsects);
for(i=0; i<4; i++) x[i] = y[i] = 0.;
for(i=0;i<nsamps;i++) {
GETIN(y,0);
ELLIPSE(x[nchout],y[nchin],ps,c,xnorm,nsects);
ADDOUT(x,1);
}
endnote(1);
}
float ellipse(x,ps,c,xnorm,nsects)
int nsects;
float x,ps[10][4],c[10][4],xnorm;
{
register int m;
float op;
for(m=0;m<nsects;m++) {
op = x + c[m][0] * ps[m][0] + c[m][2] * ps[m][1]
- c[m][1] * ps[m][2] - c[m][3] * ps[m][3];
ps[m][1] = ps[m][0];
ps[m][0] = x;
ps[m][3] = ps[m][2];
ps[m][2] = op;
x = op;
}
return(x*xnorm);
}
ellpset(list,ps,c,xnorm,nsects)
float *list,ps[10][4],c[10][4],*xnorm;
int *nsects;
{
/* the first argument in the list is the number of sections */
int m,i,j;
*nsects = (int)list[0];
i=1;
for(m=0;m < *nsects ;m++) {
for(j=0;j<4;j++) {
printf("%f %d %d %f\n",c[m][j],j,m,list[i]);
c[m][j] = list[i++];
ps[m][j] = 0;
}
}
*xnorm = list[i];
printf("xnorm %d %f %f\n",i,*xnorm,list[i-1]);
}